package lei;

import java.util.LinkedList;
import java.util.Observable;
import java.util.Observer;

import controller.delegates.EMediumMetadataUIDelegate;
import model.EMedium;
import model.EMediumAttribute;
import model.EMediumType;
import model.lendables.Lendable;
import model.rentals.BookRental;

/**
 * The document's metadata ui delegate default implementation
 * 
 * @author fmartins
 *
 */
public class LEIEMediumMetadataUIDelegate extends EMediumMetadataUIDelegate {
	
	private EMedium document;
	
	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate
	 * #setEMedium(model.EMedium)
	 */
	public void setEMedium (EMedium document) {	
		this.document=document;
	}
	
	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate
	 * #deleteObservers()
	 */
	@Override 
	public void deleteObservers() {
		document.deleteObserver(this);
	}

	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate
	 * #getDocumentBookmarks()
	 */
	@Override
	public Iterable<Integer> getDocumentBookmarks() {
		return new LinkedList<Integer>();
	}

	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate
	 * #getPageAnnotations(int)
	 */
	@Override
	public Iterable<String> getPageAnnotations(int pageNum) {
		return new LinkedList<String>();
	}

	@Override //helder
	public String getDocumentTitle() {
		return document.getTitle();
	}

	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate
	 * #addAnnotation(int, java.lang.String)
	 */
	@Override
	public void addAnnotation(int pageNum, String text) {
		BookRental aux = new BookRental(new Lendable(document.getType(), 
				document.getEMediumProperties()));
		 aux.addAnnotation(pageNum, text);
	}

	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate
	 * #removeAnnotation(int, int)
	 */
	@Override
	public void removeAnnotation(int pageNum, int annotNum) {
		
	}

	/*
	 * (non-Javadoc)
	 * @see controller.delegates.EMediumMetadataUIDelegate#toggleBookmark(int)
	 */
	@Override
	public void toggleBookmark(int pageNum) {	
	}

	@Override
	public String getAnnotationText(int pageNum, int annotNum) {
		return "";
	}

	@Override
	public void update(Observable arg0, Object hint) {
		arg0.notifyObservers(hint);
	}

}
